package com.lipy.springootrabbitmq.config.deadLetter;

import com.lipy.springootrabbitmq.config.DLXRabbitMQConfig;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
@RabbitListener(queues = DLXRabbitMQConfig.DEAD_LETTER_REDIRECT_QUEUE)
public class DeadLetterRedirectConsumer {
    @RabbitHandler
    public void consumerRedir(String msg, Channel channel, Message message){
        System.out.println("DeadLetterRedirectConsumer.consumerRedir msg"+msg);
        try {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
